<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AccountPaymentRecord extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('account_payment_record', ['comment' => '收款单据']);
        $table->addColumn('no', 'string', ['comment' => '收款单号', 'limit' => 50, 'default' => ''])
              ->addColumn('handler_id', 'integer', ['comment' => '处理人id', 'limit' => 11, 'default' => 0])
              ->addColumn('payee_id', 'integer', ['comment' => '交款人id', 'limit' => 11, 'default' => 0])
              ->addColumn('payee_type', 'integer', ['comment' => '交款人类型 1:业务员 2:司机 3门店', 'limit' => 1, 'default' => 0])
              ->addColumn('channel', 'string', ['comment' => '交款信息类型', 'limit' => 50, 'default' => ''])
              ->addColumn('pay_type', 'integer', ['comment' => '交款方式 1:现金扫码 2:公司账户', 'limit' => 1, 'default' => 0])
              ->addColumn('status', 'integer', ['comment' => '状态 1:待审核 2:已审核 3:异常', 'limit' => 1, 'default' => 1])
              ->addColumn('trade_no', 'string', ['comment' => '银行交易流水号', 'limit' => 50, 'default' => ''])
              ->addColumn('amount', 'decimal', ['comment' => '收款金额', 'precision' => 10, 'scale' => 2, 'default' => 0.00])
              ->addColumn('remark', 'string', ['comment' => '备注', 'limit' => 255, 'default' => ''])
              ->addColumn('voucher', 'string', ['comment' => '凭证', 'limit' => 255, 'default' => ''])
              ->addColumn('create_time', 'integer', ['comment' => '创建时间', 'limit' => 11, 'default' => null])
              ->addColumn('update_time', 'integer', ['comment' => '更新时间', 'limit' => 11, 'default' => null])
              ->addColumn('delete_time', 'integer', ['comment' => '删除时间', 'limit' => 11, 'default' => null])
              ->addIndex('no')
              ->addIndex('handler_id')
              ->addIndex('payee_id')
              ->addIndex('payee_type')
              ->addIndex('channel')
              ->addIndex('pay_type')
              ->addIndex('status')
              ->addIndex('trade_no')
              ->addIndex('create_time')
              ->addIndex('delete_time')
              ->create();
    }
}
